package com.probiz.estore.common.model.catalog.base;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.catalog.ProductCategory;
import com.probiz.estore.common.model.content.ProductAdvertisement;
import com.probiz.estore.common.model.product.ProductType;
import com.probiz.estore.common.model.sales.RecommendedProduct;
import com.probiz.estore.core.model.BaseObject;

/**
 * ProductCategory Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 * 产品目录表
 */
public class ProductCategoryTbl extends BaseObject implements Serializable {

    protected Integer categoryId;
	protected Short categoryType;
	protected String categoryCode;
	protected String categoryName;
	protected String categoryDescription;
	protected String keywords;
	protected String metaDescription;
	protected String templatePath;
	protected Short depth;
	protected Short hasChildren;
	protected String parentPath;
	protected String categoryPath;
	protected String imageUrl;
	protected Integer sortOrder;
	protected Short status;
	protected String displayFlag;
	protected String pinyinIndex;
	protected Integer itemCount;
	protected Integer activeItemCount;
	protected Integer createBy;
	protected Integer updateBy;
	protected java.util.Date createTime;
	protected java.util.Date updateTime;
	protected Integer version;
    protected ProductCategory parent;
    protected ProductType productType;
	protected Set children = new java.util.HashSet();
	protected Set<RecommendedProduct> recommendedProducts = new HashSet<RecommendedProduct>(); //关联的推荐商品
	protected Set<ProductAdvertisement> productAdvertisements = new HashSet<ProductAdvertisement>(); //关联的广告

	/**
	 * Default Empty Constructor for class ProductCategory
	 */
	public ProductCategoryTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class ProductCategory
	 */
	public ProductCategoryTbl (
		 Integer in_categoryId
        ) {
		this.setCategoryId(in_categoryId);
    }

    public ProductCategory getParent() {
        return parent;
    }

    public void setParent(ProductCategory parent) {
        this.parent = parent;
    }

    public ProductType getProductType() {
		return productType;
	}

	public void setProductType(ProductType productType) {
		this.productType = productType;
	}
	
	 /**
     * * @return Integer
     */
    public Integer getProductTypeId() {
        return this.getProductType() == null ? null : this.getProductType().getProductTypeId();
    }

    /**
     * Set the brandId
     */
    public void setProductTypeId(Integer aValue) {
        if (aValue == null) {
        	productType = null;
        } else {
        	productType = new ProductType(aValue);
        	productType.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }


	public Set getChildren() {
        return children;
    }

    public void setChildren(Set children) {
        this.children = children;
    }

    public Set<RecommendedProduct> getRecommendedProducts() {
		return recommendedProducts;
	}

	public void setRecommendedProducts(Set<RecommendedProduct> recommendedProducts) {
		this.recommendedProducts = recommendedProducts;
	}
	

	public Set<ProductAdvertisement> getProductAdvertisements() {
		return productAdvertisements;
	}

	public void setProductAdvertisements(
			Set<ProductAdvertisement> productAdvertisements) {
		this.productAdvertisements = productAdvertisements;
	}

	/**
	 * 	 * @return Integer
     * @hibernate.id column="categoryId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getCategoryId() {
		return this.categoryId;
	}
	
	/**
	 * Set the categoryId
	 */	
	public void setCategoryId(Integer aValue) {
		this.categoryId = aValue;
	}	

	/**
	 * 父目录id	 * @return Integer
	 */
	public Integer getParentId() {
		return this.getParent()==null?null:this.getParent().getCategoryId();
	}
	
	/**
	 * Set the parentId
	 */	
	public void setParentId(Integer aValue) {
	    if (aValue==null) {
	    	parent = null;
	    } else {
	        parent = new ProductCategory(aValue);
	        parent.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 无用，暂时保留	 * @return Short
	 * @hibernate.property column="categoryType" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getCategoryType() {
		return this.categoryType;
	}
	
	/**
	 * Set the categoryType
	 */	
	public void setCategoryType(Short aValue) {
		this.categoryType = aValue;
	}	

	/**
	 * 目录编码，ak，主要用于url生成。	 * @return String
	 * @hibernate.property column="categoryCode" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getCategoryCode() {
		return this.categoryCode;
	}
	
	/**
	 * Set the categoryCode
	 * @spring.validator type="required"
	 */	
	public void setCategoryCode(String aValue) {
		this.categoryCode = aValue;
	}	

	/**
	 * 目录名称	 * @return String
	 * @hibernate.property column="categoryName" type="java.lang.String" length="128" not-null="true" unique="false"
	 */
	public String getCategoryName() {
		return this.categoryName;
	}
	
	/**
	 * Set the categoryName
	 * @spring.validator type="required"
	 */	
	public void setCategoryName(String aValue) {
		this.categoryName = aValue;
	}	

	/**
	 * 目录描述	 * @return String
	 * @hibernate.property column="categoryDescription" type="java.lang.String" length="65535" not-null="false" unique="false"
	 */
	public String getCategoryDescription() {
		return this.categoryDescription;
	}
	
	/**
	 * Set the categoryDescription
	 */	
	public void setCategoryDescription(String aValue) {
		this.categoryDescription = aValue;
	}	

	/**
	 * 关键词、meta关键词	 * @return String
	 * @hibernate.property column="keywords" type="java.lang.String" length="256" not-null="false" unique="false"
	 */
	public String getKeywords() {
		return this.keywords;
	}
	
	/**
	 * Set the keywords
	 */	
	public void setKeywords(String aValue) {
		this.keywords = aValue;
	}	

	/**
	 * meta描述	 * @return String
	 * @hibernate.property column="metaDescription" type="java.lang.String" length="256" not-null="false" unique="false"
	 */
	public String getMetaDescription() {
		return this.metaDescription;
	}
	
	/**
	 * Set the metaDescription
	 */	
	public void setMetaDescription(String aValue) {
		this.metaDescription = aValue;
	}	

	/**
	 * 模板路径	 * @return String
	 * @hibernate.property column="templatePath" type="java.lang.String" length="128" not-null="false" unique="false"
	 */
	public String getTemplatePath() {
		return this.templatePath;
	}
	
	/**
	 * Set the templatePath
	 */	
	public void setTemplatePath(String aValue) {
		this.templatePath = aValue;
	}	

	/**
	 * 深度	 * @return Short
	 * @hibernate.property column="depth" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getDepth() {
		return this.depth;
	}
	
	/**
	 * Set the depth
	 */	
	public void setDepth(Short aValue) {
		this.depth = aValue;
	}	

	/**
	 * 是否有子目录
            1=有
            0=无	 * @return Short
	 * @hibernate.property column="hasChildren" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getHasChildren() {
		return this.hasChildren;
	}
	
	/**
	 * Set the hasChildren
	 */	
	public void setHasChildren(Short aValue) {
		this.hasChildren = aValue;
	}	

	
	public String getParentPath() {
		return parentPath;
	}

	public void setParentPath(String parentPath) {
		this.parentPath = parentPath;
	}

	/**
	 * @hibernate.property column="categoryPath" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getCategoryPath() {
		return this.categoryPath;
	}
	
	/**
	 * Set the categoryPath
	 */	
	public void setCategoryPath(String aValue) {
		this.categoryPath = aValue;
	}	

	/**
	 * 图片url	 * @return String
	 * @hibernate.property column="imageUrl" type="java.lang.String" length="255" not-null="false" unique="false"
	 */
	public String getImageUrl() {
		return this.imageUrl;
	}
	
	/**
	 * Set the imageUrl
	 */	
	public void setImageUrl(String aValue) {
		this.imageUrl = aValue;
	}	

	/**
	 * 排序值，一般值越小，越靠前	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 * @spring.validator type="required"
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * 0=前台不可见
            1=前台可见	 * @return Short
	 * @hibernate.property column="status" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getStatus() {
		return this.status;
	}
	
	/**
	 * Set the status
	 * @spring.validator type="required"
	 */	
	public void setStatus(Short aValue) {
		this.status = aValue;
	}	

	/**
	 * 自定义的显示标志
            0=标签页
            1= new
            2= hot
            可出现多个，用半角逗号分隔,最末一个也要半角逗号，如 0,2,   1,2,	 * @return String
	 * @hibernate.property column="displayFlag" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getDisplayFlag() {
		return this.displayFlag;
	}
	
	/**
	 * Set the displayFlag
	 */	
	public void setDisplayFlag(String aValue) {
		this.displayFlag = aValue;
	}	

	/**
	 * 拼音索引，例如a,b..m..	 * @return String
	 * @hibernate.property column="pinyinIndex" type="java.lang.String" length="8" not-null="false" unique="false"
	 */
	public String getPinyinIndex() {
		return this.pinyinIndex;
	}
	
	/**
	 * Set the pinyinIndex
	 */	
	public void setPinyinIndex(String aValue) {
		this.pinyinIndex = aValue;
	}	

	/**
	 * 目录下的商品的数量	 * @return Integer
	 * @hibernate.property column="itemCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getItemCount() {
		return this.itemCount;
	}
	
	/**
	 * Set the itemCount
	 */	
	public void setItemCount(Integer aValue) {
		this.itemCount = aValue;
	}	

	/**
	 * 前台可见商品个数,即上架商品个数	 * @return Integer
	 * @hibernate.property column="activeItemCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getActiveItemCount() {
		return this.activeItemCount;
	}
	
	/**
	 * Set the activeItemCount
	 */	
	public void setActiveItemCount(Integer aValue) {
		this.activeItemCount = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="createBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getCreateBy() {
		return this.createBy;
	}
	
	/**
	 * Set the createBy
	 */	
	public void setCreateBy(Integer aValue) {
		this.createBy = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="updateBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getUpdateBy() {
		return this.updateBy;
	}
	
	/**
	 * Set the updateBy
	 */	
	public void setUpdateBy(Integer aValue) {
		this.updateBy = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="createTime" type="java.util.Date" length="19" not-null="true" unique="false"
	 */
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	/**
	 * Set the createTime
	 * @spring.validator type="required"
	 */	
	public void setCreateTime(java.util.Date aValue) {
		this.createTime = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="updateTime" type="java.util.Date" length="19" not-null="true" unique="false"
	 */
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	/**
	 * Set the updateTime
	 * @spring.validator type="required"
	 */	
	public void setUpdateTime(java.util.Date aValue) {
		this.updateTime = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 * @spring.validator type="required"
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof ProductCategoryTbl)) {
			return false;
		}
		ProductCategoryTbl rhs = (ProductCategoryTbl) object;
		return new EqualsBuilder()
				.append(this.categoryId, rhs.categoryId)
						.append(this.categoryType, rhs.categoryType)
				.append(this.categoryCode, rhs.categoryCode)
				.append(this.categoryName, rhs.categoryName)
				.append(this.categoryDescription, rhs.categoryDescription)
				.append(this.keywords, rhs.keywords)
				.append(this.metaDescription, rhs.metaDescription)
				.append(this.templatePath, rhs.templatePath)
				.append(this.depth, rhs.depth)
				.append(this.hasChildren, rhs.hasChildren)
				.append(this.categoryPath, rhs.categoryPath)
				.append(this.imageUrl, rhs.imageUrl)
				.append(this.sortOrder, rhs.sortOrder)
				.append(this.status, rhs.status)
				.append(this.displayFlag, rhs.displayFlag)
				.append(this.pinyinIndex, rhs.pinyinIndex)
				.append(this.itemCount, rhs.itemCount)
				.append(this.activeItemCount, rhs.activeItemCount)
				.append(this.createBy, rhs.createBy)
				.append(this.updateBy, rhs.updateBy)
				.append(this.createTime, rhs.createTime)
				.append(this.updateTime, rhs.updateTime)
				.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.categoryId) 
						.append(this.categoryType) 
				.append(this.categoryCode) 
				.append(this.categoryName) 
				.append(this.categoryDescription) 
				.append(this.keywords) 
				.append(this.metaDescription) 
				.append(this.templatePath) 
				.append(this.depth) 
				.append(this.hasChildren) 
				.append(this.categoryPath) 
				.append(this.imageUrl) 
				.append(this.sortOrder) 
				.append(this.status) 
				.append(this.displayFlag) 
				.append(this.pinyinIndex) 
				.append(this.itemCount) 
				.append(this.activeItemCount) 
				.append(this.createBy) 
				.append(this.updateBy) 
				.append(this.createTime) 
				.append(this.updateTime) 
				.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("categoryId", this.categoryId) 
						.append("categoryType", this.categoryType) 
				.append("categoryCode", this.categoryCode) 
				.append("categoryName", this.categoryName) 
				.append("categoryDescription", this.categoryDescription) 
				.append("keywords", this.keywords) 
				.append("metaDescription", this.metaDescription) 
				.append("templatePath", this.templatePath) 
				.append("depth", this.depth) 
				.append("hasChildren", this.hasChildren) 
				.append("categoryPath", this.categoryPath) 
				.append("imageUrl", this.imageUrl) 
				.append("sortOrder", this.sortOrder) 
				.append("status", this.status) 
				.append("displayFlag", this.displayFlag) 
				.append("pinyinIndex", this.pinyinIndex) 
				.append("itemCount", this.itemCount) 
				.append("activeItemCount", this.activeItemCount) 
				.append("createBy", this.createBy) 
				.append("updateBy", this.updateBy) 
				.append("createTime", this.createTime) 
				.append("updateTime", this.updateTime) 
				.append("version", this.version) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "categoryId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return categoryId;
	}

}